package logic

import (
	da "admin/dao/auth"
	"admin/dto"
	m "admin/models/auth"
	"admin/utils/pagination"
)

// OperationLogLogic 操作日志业务逻辑
type OperationLogLogic struct {
	operationInterface da.OperationLogRepoInterface
}

// NewOperationLogLogic 创建新的操作日志逻辑实例
// repo: 操作日志仓库实例
// 返回值: 操作日志逻辑实例指针
func NewOperationLogLogic(operationInterface da.OperationLogRepoInterface) *OperationLogLogic {
	return &OperationLogLogic{
		operationInterface: operationInterface,
	}
}

// Create 创建操作日志
// log: 操作日志对象
// 返回值: 错误信息
func (l *OperationLogLogic) Create(log interface{}) error {
	return l.operationInterface.Create(log.(*m.OperationLog))
}

// List 获取操作日志列表(分页)
// page: 页码
// pageSize: 每页数量
// 返回值: 操作日志列表、总数和错误信息
func (l *OperationLogLogic) List(req dto.OperationListReq) (*pagination.PageResult[m.OperationLog], error) {
	return l.operationInterface.List(req)
}

// GetByID 根据ID获取操作日志
// id: 操作日志ID
// 返回值: 操作日志对象和错误信息
func (l *OperationLogLogic) GetByID(id int64) (*m.OperationLog, error) {
	return l.operationInterface.GetByID(id)
}
